home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / glass / glass.lha / GLASS / tmc / calu.ht < prev    next >
Text File  |  1990-11-06  |  8KB  |  373 lines

  1. /* 
  2.    Copyright (C) 1990 C van Reewijk, email: dutentb.uucp!reeuwijk
  3.  
  4. This file is part of GLASS.
  5.  
  6. GLASS is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GLASS is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GLASS; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. .. file: calu.ht
  21. .. Tm C support. Variant: array lists, union constructors.
  22. /* ---- start of ${tplfilename} ---- */
  23. /* Definition C datastructures (Version for array list).
  24.  
  25.    template file:      ${tplfilename}
  26.    datastructure file: ${dsfilename}
  27.    tm version:         $(tmvers) ($(tmdate))
  28.  */
  29.  
  30. .. forward reference typedefs for all types.
  31. .. C does not like the use of undefined types, but does not
  32. .. mind the use of pointers to (yet) undefined types.
  33. .foreach t $(need_ds_list)
  34. typedef struct str_$t_list *$t_list;
  35. .endforeach
  36. .foreach t $(need_ds)
  37. typedef struct str_$t *$t;
  38. .endforeach
  39.  
  40. .foreach t $(need_ds)
  41. #define $tNIL ($t)0
  42. .endforeach
  43. .foreach t $(need_ds_list)
  44. #define $t_listNIL ($t_list)0
  45. .endforeach
  46.  
  47. .foreach t $(need_ds)
  48. .foreach c ${conslist $t}
  49. #define $c u.ue_$c
  50. .endforeach
  51. .endforeach
  52.  
  53. .foreach t $(need_ds)
  54. .if ${len ${conslist $t}}
  55. typedef enum en_tags_$t {
  56.     ${seplist ", " ${prefix TAG ${conslist $t}}}
  57. } tags_$t;
  58.  
  59. .endif
  60. .endforeach
  61.  
  62. .foreach t $(need_ds)
  63. .. Structure definitions for all the constructors of the type
  64. .. That have elements (C does not like empty structures or unions).
  65. .. Set 'makeunion' to true if a constructor structure has been
  66. .. generated, because otherwise a union is not necessary.
  67. .set makeunion 0
  68. .if ${len ${conslist $t}}
  69. .. Constructor type
  70. .foreach c ${conslist $t}
  71. .if ${len ${celmlist $t $c}}
  72. .set makeunion 1
  73. /* Structure for constructor $c */
  74. typedef struct str_$c {
  75. .foreach sname ${celmlist $t $c}
  76. .if ${eq list ${ctypeclass $t $c $(sname)}}
  77.     ${ctypename $t $c $(sname)}_list $(sname);
  78. .else
  79.     ${ctypename $t $c $(sname)} $(sname);
  80. .endif
  81. .endforeach
  82. } C_$c;
  83.  
  84. .endif
  85. .endforeach
  86. struct str_$t {
  87.     tags_$t tag;
  88. .if $(makeunion)
  89.     union uni_$t {
  90. .foreach c ${conslist $t}
  91. .if ${len ${celmlist $t $c}}
  92.     C_$c ue_$c;
  93. .endif
  94. .endforeach
  95.     } u;
  96. .endif
  97. };
  98.  
  99. .else
  100. struct str_$t {
  101. .foreach sname ${telmlist $t}
  102. .if ${eq list ${ttypeclass $t $(sname)}}
  103.     ${ttypename $t $(sname)}_list $(sname);
  104. .else
  105.     ${ttypename $t $(sname)} $(sname);
  106. .endif
  107. .endforeach
  108. };
  109.  
  110. .endif
  111. .endforeach
  112. .foreach t $(need_ds_list)
  113. struct str_$t_list {
  114.     unsigned int sz;
  115.     unsigned int room;
  116.     $t *arr;
  117. };
  118.  
  119. .endforeach
  120.  
  121. #if defined( __STDC__ ) && __STDC__>0
  122. /* new_<cons> and new_<type> routines */
  123. .foreach t $(want_new)
  124. .if ${len ${telmlist $t}}
  125. .set tl
  126. .foreach e ${telmlist $t}
  127. .if ${eq single ${ttypeclass $t $e}}
  128. .append tl ${ttypename $t $e}
  129. .else
  130. .append tl ${ttypename $t $e}_list
  131. .endif
  132. .endforeach
  133. .if ${== ${len $(tl)} 0}
  134. extern $t new_$t( void );
  135. .else
  136. extern $t new_$t( ${seplist ", " $(tl)} );
  137. .endif
  138. .else
  139. .foreach c ${conslist $t}
  140. .set tl
  141. .foreach e ${celmlist $t $c}
  142. .if ${eq single ${ctypeclass $t $c $e}}
  143. .append tl ${ctypename $t $c $e}
  144. .else
  145. .append tl ${ctypename $t $c $e}_list
  146. .endif
  147. .endforeach
  148. .if ${== ${len $(tl)} 0}
  149. extern $t new_$c( void );
  150. .else
  151. extern $t new_$c( ${seplist ", " $(tl)} );
  152. .endif
  153. .endforeach
  154. .endif
  155. .endforeach
  156. .foreach t $(want_new_list)
  157. extern $t_list new_$t_list( void );
  158. .endforeach
  159.  
  160. /* room_<type>_list() routines */
  161. .foreach t $(want_room_list)
  162. extern void room_$t_list( $t_list, unsigned int );
  163. .endforeach
  164.  
  165. /* app_<type>_list() routines */
  166. .foreach t $(want_app_list)
  167. extern void app_$t_list( $t_list, $t );
  168. .endforeach
  169.  
  170. /* append_<type>_list() routines */
  171. .foreach t $(want_append_list)
  172. extern $t_list append_$t_list( $t_list, $t );
  173. .endforeach
  174.  
  175. /* ins_<type>_list() routines */
  176. .foreach t $(want_ins_list)
  177. extern void ins_$t_list( $t_list, unsigned int, $t  );
  178. .endforeach
  179.  
  180. /* del_<type>_list() routines */
  181. .foreach t $(want_del_list)
  182. extern void del_$t_list( $t_list, unsigned int );
  183. .endforeach
  184.  
  185. /* conc_<type>_list() routines */
  186. .foreach t $(want_conc_list)
  187. extern void conc_$t_list( $t_list, $t_list );
  188. .endforeach
  189.  
  190. /* concat_<type>_list() routines */
  191. .foreach t $(want_concat_list)
  192. extern $t_list concat_$t_list( $t_list, $t_list );
  193. .endforeach
  194.  
  195. /* fre_<type>_list() routines */
  196. .foreach t $(want_fre_list)
  197. extern void fre_$t_list( $t_list );
  198. .endforeach
  199. .foreach t $(want_fre)
  200. extern void fre_$t( $t );
  201. .endforeach
  202.  
  203. /* rfre_<type>_list() routines */
  204. .foreach t $(want_rfre_list)
  205. extern void rfre_$t_list( $t_list );
  206. .endforeach
  207. .foreach t $(want_rfre)
  208. extern void rfre_$t( $t );
  209. .endforeach
  210.  
  211. /* print_<type>() routines */
  212. .foreach t $(want_print)
  213. extern void print_$t( $t );
  214. .endforeach
  215. .foreach t $(want_print_list)
  216. extern void print_$t_list( $t_list );
  217. .endforeach
  218.  
  219. /* fprint_<type>() routines */
  220. .foreach t $(want_fprint)
  221. extern void fprint_$t( FILE *, $t );
  222. .endforeach
  223. .foreach t $(want_fprint_list)
  224. extern void fprint_$t_list( FILE *, $t_list );
  225. .endforeach
  226.  
  227. /* rdup_<type>() routines */
  228. .foreach t $(want_rdup)
  229. extern $t rdup_$t( $t );
  230. .endforeach
  231. .foreach t $(want_rdup_list)
  232. extern $t_list rdup_$t_list( $t_list );
  233. .endforeach
  234.  
  235. /* fscan_<type>() routines */
  236. .foreach t $(want_fscan)
  237. extern int fscan_$t( FILE *, $t * );
  238. .endforeach
  239. .foreach t $(want_fscan_list)
  240. extern int fscan_$t_list( FILE *, $t_list * );
  241. .endforeach
  242.  
  243. /* cmp_<type>() routines */
  244. .foreach t $(want_cmp)
  245. extern int cmp_$t( $t, $t );
  246. .endforeach
  247. .foreach t $(want_cmp_list)
  248. extern int cmp_$t_list( $t_list, $t_list );
  249. .endforeach
  250.  
  251. /* misc. functions */
  252. .if ${index flush_$(basename) $(want_misc)}
  253. extern void flush_$(basename)( void );
  254. .endif
  255. .if ${index stat_$(basename) $(want_misc)}
  256. extern void stat_$(basename)( FILE * );
  257. .endif
  258. #else
  259. /* new_<cons> and new_<type> routines */
  260. .foreach t $(want_new)
  261. .if ${len ${telmlist $t}}
  262. extern $t new_$t();
  263. .else
  264. .foreach c ${conslist $t}
  265. extern $t new_$c();
  266. .endforeach
  267. .endif
  268. .endforeach
  269. .foreach t $(want_new_list)
  270. extern $t_list new_$t_list();
  271. .endforeach
  272.  
  273. /* room_<type>_list() routines */
  274. .foreach t $(want_room_list)
  275. extern void room_$t_list();
  276. .endforeach
  277.  
  278. /* app_<type>_list() routines */
  279. .foreach t $(want_app_list)
  280. extern void app_$t_list();
  281. .endforeach
  282.  
  283. /* append_<type>_list() routines */
  284. .foreach t $(want_append_list)
  285. extern $t_list append_$t_list();
  286. .endforeach
  287.  
  288. /* ins_<type>_list() routines */
  289. .foreach t $(want_ins_list)
  290. extern void ins_$t_list();
  291. .endforeach
  292.  
  293. /* del_<type>_list() routines */
  294. .foreach t $(want_del_list)
  295. extern void del_$t_list();
  296. .endforeach
  297.  
  298. /* conc_<type>_list() routines */
  299. .foreach t $(want_conc_list)
  300. extern void conc_$t_list();
  301. .endforeach
  302.  
  303. /* concat_<type>_list() routines */
  304. .foreach t $(want_concat_list)
  305. extern $t_list concat_$t_list();
  306. .endforeach
  307.  
  308. /* fre_<type>_list() routines */
  309. .foreach t $(want_fre_list)
  310. extern void fre_$t_list();
  311. .endforeach
  312. .foreach t $(want_fre)
  313. extern void fre_$t();
  314. .endforeach
  315.  
  316. /* rfre_<type>_list() routines */
  317. .foreach t $(want_rfre_list)
  318. extern void rfre_$t_list();
  319. .endforeach
  320. .foreach t $(want_rfre)
  321. extern void rfre_$t();
  322. .endforeach
  323.  
  324. /* print_<type>() routines */
  325. .foreach t $(want_print)
  326. extern void print_$t();
  327. .endforeach
  328. .foreach t $(want_print_list)
  329. extern void print_$t_list();
  330. .endforeach
  331.  
  332. /* fprint_<type>() routines */
  333. .foreach t $(want_fprint)
  334. extern void fprint_$t();
  335. .endforeach
  336. .foreach t $(want_fprint_list)
  337. extern void fprint_$t_list();
  338. .endforeach
  339.  
  340. /* rdup_<type>() routines */
  341. .foreach t $(want_rdup)
  342. extern $t rdup_$t();
  343. .endforeach
  344. .foreach t $(want_rdup_list)
  345. extern $t_list rdup_$t_list();
  346. .endforeach
  347.  
  348. /* fscan_<type>() routines */
  349. .foreach t $(want_fscan)
  350. extern int fscan_$t();
  351. .endforeach
  352. .foreach t $(want_fscan_list)
  353. extern int fscan_$t_list();
  354. .endforeach
  355.  
  356. /* cmp_<type>() routines */
  357. .foreach t $(want_cmp)
  358. extern int cmp_$t();
  359. .endforeach
  360. .foreach t $(want_cmp_list)
  361. extern int cmp_$t_list();
  362. .endforeach
  363.  
  364. /* misc. functions */
  365. .if ${index flush_$(basename) $(want_misc)}
  366. extern void flush_$(basename)();
  367. .endif
  368. .if ${index stat_$(basename) $(want_misc)}
  369. extern void stat_$(basename)();
  370. .endif
  371. #endif
  372. /* ---- end of ${tplfilename} ---- */
  373.